********************************************************************************
*** REPLICATION CODE ***********************************************************
*** Ennser-Jedenastik, Laurenz (forthcoming). "What Drives Partisan Conflict ***
*** and Consensus on Welfare State Issues?", Journal of Public Policy. *********
*** Accepted for publication on 02 August 2020 *********************************
********************************************************************************

*** set directory
cd "W:\Democratic Governance\Projekte\Papiere\Welfare Policy\25 Partisan conflict\02 paper\JPP Submission\05 Replication data"




**************************************
*** TABLE 1, row 1 (Assumption H1) ***
**************************************

use "01_autnes.dta", clear

svyset _n [pweight=weight]
recode w1_q26x2 w1_q27 (77/99=.)

gen reduceincdiff = w1_q26x2
recode reduceincdiff (1/2=1) (3=2) (4/5=3)
label define reduceincdiff 1 "agree (strongly)" 2 "neither agree nor disagree" 3 "disagree (strongly)"
label values reduceincdiff reduceincdiff 
svy: tab reduceincdiff if inrange(w1_q27, 0, 10)

gen taxes_benefits = w1_q27
recode taxes_benefits (0/4=1) (5=2) (6/10=3)
label define taxes_benefits 1 "0-4" 2 "5" 3 "6-10"
label values taxes_benefits taxes_benefits
svy: tab taxes_benefits



**************************************
*** TABLE 1, row 2 (Assumption H2) ***
**************************************

use "02_evs.dta", clear

gen elderly = v217 
gen unempl = v218
gen immigr = v219
gen sick = v220
recode elderly unempl immigr sick (-2/-1=.) (1/2=1) (3/5=0)

tab elderly
tab sick
tab unempl
tab immigr



**************************************
*** TABLE 1, row 3 (Assumption H3) ***
**************************************

use "03_ess.dta", clear
svyset _n [pweight=pspwght]
gen leftright3 = lrscale
recode leftright3 (0/3=1) (4/6=.) (7/10=2)
label define leftright3 1 "Left" 2 "Right"
label values leftright3 leftright3
svy: tab earnpen leftright3, col
svy: tab earnueb leftright3, col






*** load manifesto data
use "04_autnes_manifesto.dta", clear


***************************************************************
*** FIGURE 1: Salience of social policy in party manifestos ***
***************************************************************

gen party2 = party / 100000
recode party2 (19=24) (15 = 25)
label define party2 11 "SPÖ" 12 "ÖVP" 13 "FPÖ" 14 "Greens" 24 "LF/Neos" 25 "BZÖ"
label values party2 party2
twoway connected socialsal year, by(party2) yscale(range(0 30)) l1title("Salience of social policy")



********************************************************************
*** FIGURE 2: Proportion of pro-retrenchment statements by party ***
********************************************************************

bysort py: egen retrench_by_py = mean(retrench)
twoway connected retrench_by_py year, by(party2) yscale(range(0 .8))



********************************************************************************************
*** FIGURE 3: Proportion of retrenchment statements for left-wing and right-wing parties ***
****** by revenue & expenditure, deservingness, and redistribution *************************
********************************************************************************************

* NB: Original graph is vertical (here: horizontal)
gen retrench_L = retrench if left == 0
gen retrench_R = retrench if left == 1
graph dot retrench_L retrench_R, over(rev_exp) yscale(range(0 0.8)) name(Fig3_1) legend(label(1 "Right") label(2 "Left")) nodraw
graph dot retrench_L retrench_R, over(deserv_num) yscale(range(0 0.8)) name(Fig3_2) legend(label(1 "Right") label(2 "Left")) nodraw
graph dot retrench_L retrench_R, over(redist_num) yscale(range(0 0.8)) name(Fig3_3) legend(label(1 "Right") label(2 "Left")) nodraw
graph combine Fig3_1 Fig3_2 Fig3_3, title("Proportion of pro-retrenchment statements (Figure 3)")



****************************************************************************
*** TABLE 4: Binary logistic regression (DV: pro-retrenchment statement) ***
****************************************************************************

* NB: procedure adopted from Gu & Yoo (The Stata Journal, Vol. 19, Iss. 4, 2019, page 4)
program define mymway, eclass
melogit retrench i.left##i.rev_exp i.left##ib1.deserv_num i.left##ib1.redist_num /// 
  i.left##ib2.design_num i.left##i.instref i.left##i.crosscut i.left##i.decade || py:, vce(cluster party) nolog
matrix V_party = e(V)
melogit retrench i.left##i.rev_exp i.left##ib1.deserv_num i.left##ib1.redist_num /// 
  i.left##ib2.design_num i.left##i.instref i.left##i.crosscut i.left##i.decade || py:, vce(cluster year) nolog
matrix V_year = e(V)
melogit retrench i.left##i.rev_exp i.left##ib1.deserv_num i.left##ib1.redist_num /// 
  i.left##ib2.design_num i.left##i.instref i.left##i.crosscut i.left##i.decade || py:, vce(cluster py) nolog
matrix V_py = e(V)
matrix V_mway = V_party + V_year - V_py
ereturn repost V = V_mway
ereturn scalar df_r = .
melogit
end

mymway
estimates store model_multiway_cluster
esttab model_multiway_cluster, drop(0* *0.inst* *0.cross*) wide s(N N_clust ll) se replace varwidth(20)



********************************************************************
*** FIGURE 4: Average marginal effects (AMEs) of left party ********
****** by revenue/expenditure, deservingness, and redistribution ***
********************************************************************

* NB: only works after execution of regression command above (Table 4)
margins, dydx(left) at(rev_exp = (0/2)) asobserved plot
margins, dydx(left) at(deserv_num = (1/3)) asobserved plot
margins, dydx(left) at(redist_num = (1/4)) asobserved plot

